Method and system for detection of remote file inclusion vulnerabilities

ABSTRACT

A method for detecting remote file inclusion vulnerabilities in a web application includes altering of extracted resource references from a web application, submission of altered references as HTTP requests to the web application, inspection of corresponding HTTP responses, and diagnosis of vulnerability. A system of invention implements the method.

CROSS REFERENCE TO RELATED APPLICATIONS

The present application claims priority from U.S. Provisional PatentApplication No. 60/887,801 filed Feb. 1, 2007, the contents of which areherein incorporated by reference in their entirety.

FIELD OF THE INVENTION

The present invention relates to computer security and, moreparticularly, to the detection of vulnerabilities in web applications.

BACKGROUND OF THE INVENTION

The popularity of the Internet has given rise to e-commerce. Asillustrated in FIG. 1, many consumers utilize devices with Internetconnectivity 102 to enjoy conveniences such as shopping at home viashopping and auction websites 104 and banking at home via on-linebanking websites 104. Many other activities that formerly required liveinteractions either in person or via phone can be conducted on-line,such as applying for car or health insurance, buying and selling stocks,etc. via the Internet 106.

Such on-line activities typically require the exchange and storage ofpersonal information such as credit card numbers and bankinginformation. Accordingly, consumers want to be able to trust that thewebsites 104 are secure from on-line vulnerabilities, such as theability for hackers to gain access to their personal information.

The inventions and technologies described in co-pending U.S. patentapplication Ser. Nos. 10/113,875 and 10/674,878, the contents of whichare incorporated herein by reference, have dramatically advanced thestate of the art of vulnerability detection, assessment and management.For example, these co-pending applications describe techniques forperforming vulnerability scans of websites, and hosting and controllingthe contents of a mark in accordance with the scan results thatindicates to visitors of the website how safe the website is. Thesevulnerability scans aim to duplicate and/or exploit methods known to beused by hackers to attempt to gain unauthorized access to the devicesand systems of the website. Nevertheless, areas of potential improvementexist.

Websites such as 104 are accessed by client software programs over theInternet via a protocol known as Hypertext Transfer Protocol (or HTTP).Using an HTTP request, a client can ask for specific content from awebsite and/or send user data to the website. Per the specification ofthe request, the website generates content and returns the content tothe client via a corresponding HTTP response. A web browser (e.g.Internet Explorer) is the most common example of an HTTP client. Webbrowsers make HTTP requests when users type in URLs or click on links orsubmit forms present in the content of the website. In the specific caseof submitting a form, information keyed into the form by the user isincluded with the HTTP request. When generating content for a response,websites often dynamically construct code based on an HTTP request; andthe code is executed by a corresponding interpreter. Dynamicallyconstructed SQL statements executed by a relational database are themost common example, but any other language and interpreter includingRuby, PHP, PERL, Python, etc. can serve.

Accordingly, many web applications employ interpreters capable ofexecuting source code from various programming languages. Many of theselanguages are suited specifically for web application development andsupport concise programmatic directives for including source code fromremote locations. These directives allow common resources to be reusedand composed dynamically across a network into more elaborateconstructs, eliminating redundancy in the creation of source code and inthe deployment of application resources.

The ability to cause a web application to illicitly include an externalresource and attempt to execute the resource as part of theapplication's operation is known as remote file inclusion. This class ofvulnerability is potentially severe as the web application can beinstructed to execute arbitrary malicious code, such as code from ahacker who wants to disrupt or surreptitiously access the webapplication.

For example, a web application using the popular PHP programminglanguage might include a line of code that looks like “include $foo;”. Aprogrammer may have errantly allowed the variable “foo” to be assignedwith unfiltered data from an HTTP request. A hacker, knowing orsuspecting this vulnerability, may send an HTTP request to the webapplication, and surreptitiously include in the request a directive thatre-assigns the variable “foo” to a URL controlled by the hacker andpointing to malicious code. Then, upon the next execution of the givenline, the PHP interpreter will attempt to load and execute the resourceof the hacker's URL, which could be potentially damaging to the websiteand/or its users.

Accordingly, there remains a need in the art for a method and apparatusto effectively detect vulnerabilities such as remote file inclusion.

SUMMARY OF THE INVENTION

The invention provides a method and system for detecting remote fileinclusion vulnerabilities in web applications. According to certainaspects, during a security scan, references to resources are extractedfrom the content of a web application. The references are altered torefer to resources under control of the party conducting the securityscan. In embodiments, the altered references are submitted as HTTPrequests to the web application, and the corresponding responses areanalyzed. The resources referenced as a result of altering theoriginally extracted resource references are programmatic codemeaningful to various programming language interpreters of interest. Thecode instructs an interpreter to render, print, or otherwise output aunique identifying value or signature. Analysis of an HTTP responseincludes looking for evidence of execution of the external code by theweb application. For example, if the signature is present in lieu ofinstructions to output the signature, it is determined that the code hasbeen executed by the web application and that the web application is,therefore, vulnerable to remove file inclusion attacks.

BRIEF DESCRIPTION OF THE DRAWINGS

These and other aspects and features of the present invention willbecome apparent to those ordinarily skilled in the art upon review ofthe following description of specific embodiments of the invention inconjunction with the accompanying figures, wherein:

FIG. 1 illustrates how users interact with conventional websites;

FIG. 2 is a block diagram illustrating an example system that implementsaspects of remote file inclusion vulnerability detection according tothe invention;

FIG. 3 is a flowchart illustrating an example remote file inclusionvulnerability detection method of the invention; and

FIG. 4 is a diagram illustrating steps performed by a detection methodaccording to the invention in alternate detail.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

The present invention will now be described in detail with reference tothe drawings, which are provided as illustrative examples of theinvention so as to enable those skilled in the art to practice theinvention. Notably, the figures and examples below are not meant tolimit the scope of the present invention to a single embodiment, butother embodiments are possible by way of interchange of some or all ofthe described or illustrated elements. Moreover, where certain elementsof the present invention can be partially or fully implemented usingknown components, only those portions of such known components that arenecessary for an understanding of the present invention will bedescribed, and detailed descriptions of other portions of such knowncomponents will be omitted so as not to obscure the invention. In thepresent specification, an embodiment showing a singular component shouldnot be considered limiting; rather, the invention is intended toencompass other embodiments including a plurality of the same component,and vice-versa, unless explicitly stated otherwise herein. Moreover,applicants do not intend for any term in the specification or claims tobe ascribed an uncommon or special meaning unless explicitly set forthas such. Further, the present invention encompasses present and futureknown equivalents to the known components referred to herein by way ofillustration.

In general, the invention detects server side inclusion vulnerabilitiesby looking for signatures embedded in content provided by its own HTTPserver(s). To verify the presence of the vulnerability, the inventionissues HTTP requests to the website that instruct it to dynamicallyinclude its own signature content in subsequent HTTP responses. If asignature is detected in subsequent responses, the invention concludesthat the website is vulnerable.

A block diagram illustrating an example system for implementing theinvention is shown in FIG. 2. As shown in FIG. 2, remote file inclusionvulnerability detection system 202 analyzes a target network 206 via anetwork 204, such as the Internet.

In embodiments, detection system 202 can be part of a network ofdistributed scanning servers, for example located in data centers thatare geographically dispersed around the world. In embodiments, detectionsystem 202 can include a local scan appliance that is controlled by acentral vulnerability management system, so that the most suitable scanappliance is assigned to test the target system. Additionally oralternatively, the remote file inclusion vulnerability detectiontechniques of the invention can be implemented by detection system 202in addition to a more comprehensive set of vulnerability detectionmethods against target systems, such as those provided by conventionalscanning services such as ScanAlert of Napa, Calif., and those describedin the co-pending applications.

According to aspects of the invention, detection system 202 accesses arepository 220 for providing the programmatic content necessary for thedetection of remote file inclusion vulnerabilities. In embodiments, therepository is a file system but can also be a relational database orother effective means of storage. The contents of repository 220 aremade accessible over the Internet via a web server (not shown) such thateach repository entry can be retrieved using a corresponding URL. Insome embodiments, the web server and repository 220 are co-locatedand/or provided together with detection system 202. In otherembodiments, repository 220 and an associated web server are separatelyprovided from detection system 202.

In embodiments, for each programming language of interest, acorresponding entry is stored in repository 220, the entry having anassociated URL. Languages of interest include but are not limited toPHP, JSP, and ASP. As will be described in more detail below, each entryinstructs an interpreter for the language associated with the entry tooutput a signature.

Networked target system 206 (e.g. a website) provides one or more webapplications 208 accessible over the Internet 204 or other network viathe HTTP protocol and one or more HTTP servers 212.

Detection system 202 can use web application scanning techniques knownto those skilled in the art, including those developed by ScanAlert ofNapa, Calif., and those described in the co-pending applications, todetermine the supported interpreters 210 of system 202. Detection system202's web application security scanner further traverses the content ofweb application 208 to identify resources that reference other contentin the web application. References can include URLs in attributes ofHTML elements, HTML forms, JavaScript directives for setting documentlocations, Flash forms, Flash URLs, backing file system directorylistings, and references from site traversal assistance includingSitemaps and Robots files.

Detection system 202 alters these references using a technique known asinjection. Injection provides a new value or replaces an existing valuewithin some part of the structure of an HTTP request. Injection pointsare identified from the input controls found above, and can include formfield values, URL query string field values, HTTP request header values,URL path elements, URL fragments, form field names, URL query stringfield names, HTTP request header names, and sub-tokens of each of theprior based on punctuated delimitation. Each injection point is suppliedwith a URL that references a distinct entry in repository 220.Accordingly, if N injection points are identified, and repository 220includes M entries and corresponding URLs, a possible N×M HTTP requestscan be generated to test target system 206 for remote file inclusion.Detection system 202 issues these altered requests to the webapplication via the HTTP protocol and system 206's HTTP server 212.

Responses from target system 206 associated with code executed from theentries in repository 220, and resulting from the altered references,are stored in 222. Detection system 202 inspects each HTTP response in222 for evidence of remote file inclusion. Specifically, system 202determines whether the response contains one or more signaturescorresponding to the entries in the code repository 220. If so,detection system 202 detects that system 206 has a remote file inclusionvulnerability.

An example vulnerability detection methodology in accordance withaspects of the invention will now be described in connection with FIG.3.

As shown in FIG. 3, in a first step S302, each injection point into thetarget system is determined. For example, where the target system is aweb site (e.g. www.example.com), the web site can be crawled to identifyflash embedded links and password protected pages, to find forms andother potentially dangerous user-controlled elements. Injection pointsare identified from these forms and elements, and can include form fieldvalues, URL query string field values, HTTP request header values, URLpath elements, URL fragments, form field names, URL query string fieldnames, HTTP request header names, and sub-tokens of each of the priorbased on punctuated delimitation.

In a next step S304, the content of web application is scanned toidentify resources that reference other content in the web application.This can be done using known crawling techniques. For example, detectionsystem 202 can make HTTP requests using the injection points identifiedabove, and receive responses from the server in system 206 to which therequests were made. Detection system 202 then scans the response toidentify resources that reference content. References can include URLsin attributes of HTML elements, HTML forms, JavaScript directives forsetting document locations, Flash forms, Flash URLs, backing file systemdirectory listings, and references from site traversal assistanceincluding Sitemaps and Robots files.

For each reference, and for each injection point, identified above, andas determined in step S306, one or more HTTP requests having an alteredreference assignment is constructed in step S308. For example, thedetection system can use the GET method to issue a request from thetarget system's HTTP server in the form of www.example.com/<forminput><reference=entry URL>, where <form input> depends on theparticular injection point being exploited and <reference=entry URL> isinjected input that assigns the reference (e.g. a variable such as“foo”) to the URL for an entry in repository 220. The exact contents ofthe string <form input> depend on the forms and interactive elementsidentified in step S302. In embodiments, a plurality of HTTP requestswill be constructed, one for each programming language of interest andcorresponding entry in repository 220 (and so steps S308 to S314 will berepeated for each).

As mentioned above, the URL injected into an HTTP request in step S308refers to code in repository 220 that causes an associated interpreterto generate output that leaves no doubt that the code was executed bythe interpreter. For example, code for the PHP language can include aline of “print(md5(‘abcdefg’));”. This instructs PHP to output the MD5hash of the value “abcdefg”. The corresponding output of“7ac66c0f148de9519b8bd264312c4d64” (as opposed to just the string“abcdefg”) is highly unique and suitable for use as a signature toirrefutably establish that the PHP code was executed.

In step S310, detection system 202 issues the constructed HTTPrequest(s) to the target site. The target site responds with an HTTPresponse. If the target site has a remote file inclusion vulnerability,the response will bear the remote file include signature.

An example of the exchange performed in accordance with this method isfurther illustrated in FIG. 4. As shown and as described above inconnection with step S304, (1) using an injection point identified instep S302, detection system 202 issues an HTTP request to the targetsystem 206. (2) The target system responds with an HTTP response, whichmay include a reference as described above. (3) Detection system 202then modifies the reference in this HTTP response as described above inconnection with step S308, for example to reference the resourcehttp://www.scanalert.com/1.asp, which resource is stored in repository220 and available with this URL (4) The modified resource is sent to thetarget system 206 via the constructed HTTP request, as described abovein connection with step S310. (5) The web server of the target system206 uses the modified resource to request information from the detectionsystem's web server (e.g. the resource http://www.scanalert.com/1.asp).(6) The detection system's server sends the requested resource (i.e.non-rendered code) back to the web server of the target system 206. Ifthe target system has a remote file inclusion vulnerability, it willrender this content and (7) the rendered content will be sent from theweb server of the target system 206 to the detection system 202 in aHTTP response.

Returning to FIG. 3, in step S312, detection system 202 receives theresponse and inspects it for the presence of a signature. If thesignature is present, as determined in step S314, the target system isdetermined to be vulnerable.

It should be noted that the directive to output the signature must beabsent in the response. For instance, it is not sufficient to inspect aresponse for a signature of “7ac66c0f148de9519b8bd264312c4d64” if thecorresponding code is “print(‘7ac66c0f148de9519b8bd264312c4d64’);”.“7ac66c0f148de9519b8bd264312c4d64” must be present, but“print(‘7ac66c0f148de9519b8bd264312c4d64’);” must not be present. Thepresence of a signature with the mentioned caveat establishes codeexecution.

It should be further noted that, for each programming language ofinterest, the signature should preferably be unique. Consequently, notonly can it be established that a web application is vulnerable toremote file inclusion; but it can also be established that the webapplication executes one or more specific programming languages.

Processing returns to step S306 until all the detected references andinjection points have been tested.

Although the present invention has been particularly described withreference to the preferred embodiments thereof, it should be readilyapparent to those of ordinary skill in the art that changes andmodifications in the form and details may be made without departing fromthe spirit and scope of the invention. It is intended that the appendedclaims encompass such changes and modifications.

1. A method for identifying a vulnerability of a web application,comprising: extracting a resource reference from a web application;altering the extracted reference by supplying a uniform resource locator(URL) that references one of a plurality of entries in a repository;sending the altered reference to the web application; providingexecutable code for remote file inclusion within each of the pluralityof entries in the repository, wherein the executable code within each ofthe plurality of entries instructs an interpreter of a differentprogramming language to generate a signature; and inspecting a responsefrom the web application for presence of the signature to determinewhether the web application executed the executable code, wherein thesignature is unique for a given programming language.
 2. A methodaccording to claim 1, wherein presence of the unique signature indicatesthat the web application employs an interpreter for a programminglanguage corresponding to the unique signature.
 3. A method according toclaim 1, further comprising identifying an injection point of the webapplication to be utilized in the act of sending the altered referenceto the web application.
 4. A method according to claim 3, wherein theact of sending the altered reference to the web application comprisesconstructing an HTTP request based on the identified injection pointhaving the altered reference.
 5. A method according to claim 1, whereinthe act of sending the altered reference to the web applicationcomprises constructing an HTTP request having the altered reference. 6.A method according to claim 1, wherein the acts of altering theextracted reference and sending the altered reference to the webapplication are repeated for each of the plurality of entries in therepository.
 7. A method according to claim 6, wherein presence of thesignature that is unique for a given programming language in theresponse indicates that the web application employs an interpreter forthe given programming language.
 8. A system for identifying avulnerability of a web application, comprising: a vulnerability detectorthat is adapted to extract a resource reference from the webapplication, alter the extracted reference, and send the alteredreference to the web application; a repository that stores executablecode within a plurality of entries that are capable of being referencedby a uniform resource locator (URL) supplied as part of the alteredreference, wherein the executable code within each of the plurality ofentries instructs an interpreter of a different programming language togenerate a signature, wherein the vulnerability detector is furtheradapted to inspect a response from the web application for presence ofthe signature to determine whether the web application executed theexecutable code, wherein the signature is unique for a given programminglanguage.
 9. A system according to claim 8, wherein presence of theunique signature indicates that the web application employs aninterpreter for a programming language corresponding to the uniquesignature.
 10. A system according to claim 8, wherein the vulnerabilitydetector is further adapted to identify an injection point of the webapplication to be utilized to send the altered reference to the webapplication.
 11. A system according to claim 10, wherein sending thealtered reference to the web application comprises constructing an HTTPrequest based on the identified injection point having the alteredreference.
 12. A system according to claim 8, wherein sending thealtered reference to the web application comprises constructing an HTTPrequest having the altered reference.